Import('env')
Import('options')
env = env.Copy()

CC = env['CC']
PLATFORM = env['PLATFORM']
if CC in ('cl', 'msvc', 'icc'):
    env.Append(CCFLAGS=['/O2'])
elif CC in ('gcc',):
    if PLATFORM == 'darwin':
        env.Append(CCFLAGS=['-O2', '-pipe', '-fPIC', '-funsigned-char', '-ffast-math', '-mpowerpc' , '-mtune=G4'])
    elif PLATFORM == 'sunos':
        env.Append(CCFLAGS=['Xc', '-v', '-fast'])
    else:
        env.Append(CCFLAGS=['-O2', '-ansi'])
else:
    raise 'Unknown compiler'

sourceFiles = [
    'src/geom.c',
    'src/geom2.c',
    'src/global.c',
    'src/io.c',
    'src/mem.c',
    'src/merge.c',
    'src/poly.c',
    'src/poly2.c',
    'src/qhull.c',
    'src/qset.c',
    'src/stat.c',
    'src/user.c',
]
env.Append(CPPPATH=['include', 'src'])
env.Library(target='#$BUILD_DIR/lib/extern_qhull', source=sourceFiles)
